<?php
/*IMPORTANT: 注意检查文件字符集是否为UTF-8*/
require_once "./include/main.inc.php";
require_once "./addon/main.inc.php";
if(@$_GET['service']=="httptrack"&&@$_GET['role']=="WEIKAN"&&@$_GET['response'])
{
	$s = new httptrack;
	$s->NewTrack($_GET['role'],$_GET['response'],'http://ns.weikan.cn/');
	echo "accepted";
	exit();
}
if(@$_GET['service']=="showhttptrack"&&@$_GET['contenttype']=="json")
{
	$s = new httptrack;
	echo json_encode($s->LoadTrackList());
	exit();
}
if(@$_GET['service']=="showhttptrack")
{
	$s = new httptrack;
	$d = $s->LoadTrackList();
	header("Content-type:text/html ;charset=utf-8");
	echo "<h4>CDN连通性能监测</h4>";
	echo "<table border=1><tr><td>id</td><td>名称</td><td>连通情况</td><td>最后更新时间</td><td>操作</td></tr><tr><td>{$d[0][0]}</td><td>http://ns.weikan.cn/</td><td>err/tot:{$d[0][3]}/{$d[0][2]}</td><td>{$d[0][4]}(UTC)</td><td><a href=\"http://172.16.10.208/sqlitemanager/main.php?dbsel=2&table=HT_WEIKAN&action=browseItem&DisplayQuery=SELECT+*+FROM+%27HT_WEIKAN%27&sortBrowse=0\" style=\"color:#555\" target=\"blank\">show logs</a>/<a href=\"http://172.16.10.208/sqlitemanager/main.php?dbsel=2&table=HT_WEIKAN&action=browseItem&DisplayQuery=SELECT+*+FROM+%27HT_WEIKAN%27+WHERE+response+%3C%3E+%27OK%27&sortBrowse=0\" style=\"color:#555\" target=\"blank\">show errors</a></td></tr></table>";
	exit();
}
echo "Service Unreachable";
?>